import java.io.Serializable;



/**
 * 
 */

/**
 * @author Plamen Jeliazkov
 *
 */
public class Pledge implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 8121404165830908239L;
	public static final int INSTRUCTIONS = -1;
	public static final int STAGE1_WORKING = 0;
	public static final int STAGE1_DONE = 1;
	public static final int WAITING = 2;
	public static final int DONE = 3;
	public static final int SURVEY = 4;
	public static final int CHANCE = 0;
	public static final int VALUE = 1;
	public static final int ALL_RANDOM = 0;
	public static final int GAINS_FIRST = 1;
	public static final int LOSSES_FIRST = 2;
	
	double ratio;
	double x;
	double y;
	double max;
	double given;
	double money;
	int index;
	String ID;
	boolean sorted;
	boolean mustscale;
	double payout;
	double othersTotalGiven;
	
	long timeToDecide;
	
	double lastrate;
	double lastx;
	double lastgiven;
	double lastAllgiven;
	
	//empty constructor
	public Pledge() {
		this.ratio = 0;
		this.x = 0;
		this.y = 0;
		this.sorted = false;
		this.index = 0;
		this.given = 0;
		this.money = 0;
		this.mustscale = false;
		this.max = 0;
		this.payout = 0;
		this.othersTotalGiven = 0;
		this.lastgiven = 0;
		this.lastAllgiven = 0;
	}
	
	//constructor used for demo purposes
	public Pledge(double ratio, double thres, double money, int index) {
		this.ratio = ratio;
		//how much we will give in total
		this.x = (ratio * thres);
		//how much we expect others to give in total
		this.y = thres;
		this.max = money;
		this.sorted = false;
		this.index = index;
		this.given = 0;
		this.money = money;
		this.mustscale = false;
		this.payout = 0;
		this.othersTotalGiven = 0;
	}
	
	//called to prepare the full pledges
	public void prepare(double ratio, double thres, int index)
	{
		this.ratio = ratio;
		this.x = (ratio * thres);
		this.y = thres;
		this.max = thres;
		this.index = index;
		this.mustscale = false;
		this.sorted = false;
	}
	
	
//	public Pledge(int x, int y, int index) {
//		this.ratio = (double) x/y;
//		this.x = x;
//		this.y = y;
//		this.sorted = false;
//		this.index = index;
//		this.mustscale = false;
//	}
}
